// 'js/skoll.struct.js' START:
/**
 * @file skoll.struct.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll = {
	configLeeches: [],
	config: {
		loaded: false
	},
	actions: {
		content: {},
		info: {},
		menu: {},
		rule: {},
		sidetools: {}
	},
	layouts: {},
	tools: {}
};// 'js/skoll.struct.js' END
// 'js/skoll.config.js' START:
/**
 * @file skoll.config.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.configLeechesRun = function() {
	if (Skoll.config.loaded) {
		Skoll.configLeeches.forEach(function(func) {
			if (typeof func == "function") {
				func();
			}

			Skoll.configLeeches.splice(Skoll.configLeeches.indexOf(func), 1);
		});
	} else if (!Skoll._configLeechesRunning) {
		Skoll._configLeechesRunning = true;
		setTimeout(function() {
			Skoll._configLeechesRunning = false;
			Skoll.configLeechesRun();
		}, 100);
	}
};
Skoll._configLeechesRunning = false;

$("script[src*='js/skoll.full.js'],script[src*='js/skoll.min.js']").on("load", function() {
	$.ajax({
		dataType: "json",
		url: $(this).attr("src").dirname().dirname() + "/config.json",
		success: function(data) {
			Skoll.config = data;
			Skoll.config.loaded = true;
			Skoll.configLeechesRun();
		},
		error: function(data) {
			Skoll.config.loaded = true;
			Skoll.tools.log("Skoll seems to have no configuration");
		}
	});
});

$(document).ready(function() {
	Skoll.configLeechesRun();
});// 'js/skoll.config.js' END
// 'js/skoll.tools.js' START:
/**
 * @file skoll.tools.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll skin tools collection.
 * @{
 */
Skoll.tools._logPrefix = "SkollLog: ";
Skoll.tools.log = function(obj) {
	if (typeof Skoll.config.debug == "undefined" || Skoll.config.debug) {
		if (typeof obj == "string") {
			console.log(Skoll.tools._logPrefix + obj);
		} else {
			console.log(Skoll.tools._logPrefix);
			console.log(obj);
		}
	}
}
Skoll.tools.extraUrlParams = function() {
	var url = window.location.href;
	var out = "";

	var pattern = /^(.*)([\&\?])(nocache|resetcache)([^\&\?]*)(.*)$/;
	if (url.match(pattern)) {
		out += url.replace(pattern, '&$3');
	}
	var pattern = /^(.*)([\&\?])(nolang)([^\&\?]*)(.*)$/;
	if (url.match(pattern)) {
		out += url.replace(pattern, '&$3');
	}
	var pattern = /^(.*)([\&\?])(wclang)([^\&\?]*)(.*)$/;
	if (url.match(pattern)) {
		out += url.replace(pattern, '&$3$4');
	}

	return out;
};
Skoll.tools.preventDefault = function(event) {
	if (typeof event == "undefined" && typeof window.event != "undefined") {
		event = window.event;
	}
	if (typeof event != "undefined") {
		if (event.preventDefault) {
			event.preventDefault();
		} else {
			// Bloody IE
			event.returnValue = false;
		}
		if (event.stopPropagation) {
			event.stopPropagation();
		}
	}
};
Skoll.tools.reload = function() {
	Skoll.tools.preventDefault();
	window.location.reload();
};
Skoll.tools.reloadHome = function() {
	Skoll.tools.preventDefault();
	window.location.href = "?group=" + GROUP_ID;
};
Skoll.tools.switchGroup = function(id) {
	Skoll.tools.preventDefault();
	window.location.href = "?group=" + id;
};
/** @} */

String.prototype.basename = function() {
	return this.replace(/(^.*)\/([^\/\\]*)$/, '$2');
};
String.prototype.dirname = function() {
	return this.replace(/(^.*)\/([^\/\\]*)$/, '$1');
};
// 'js/skoll.tools.js' END
// 'js/skoll.tools.baloon.js' START:
/**
 * @file skoll.tools.baloon.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll loading screen.
 */
Skoll.tools.Baloon = {
	//
	// Protected properties.
	_container: null,
	_delay: 3000,
	_lastId: 0,
	//
	// Public methods.
	message: function(message, delay) {
		if (typeof delay === "undefined") {
			delay = Skoll.tools.Baloon._delay;
		}

		Skoll.tools.Baloon._initContainer();

		var id = "SkollBaloon_" + Skoll.tools.Baloon._lastId;
		Skoll.tools.Baloon._lastId++;
		Skoll.tools.Baloon._container.append('<div id="' + id + '" class="PopUp" hidden="hidden">' + message + '</div>');
		console.log($("#SkollBaloonContainer"));

		$("#" + id).fadeIn(function() {
			window.setTimeout(function() {
				$("#" + id).fadeOut(function() {
					$(this).remove();
				});
			}, delay);
		});
	},
	//
	// Protected methods.
	_initContainer: function() {
		if (Skoll.tools.Baloon._container === null) {
			$("body").append('<div id="SkollBaloonContainer" class="PopUpContainer"></div>');
			Skoll.tools.Baloon._container = $("#SkollBaloonContainer");
		}
	}
};// 'js/skoll.tools.baloon.js' END
// 'js/skoll.tools.loading.js' START:
/**
 * @file skoll.tools.loading.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll loading screen.
 */
Skoll.tools.Loading = {
	//
	// Protected properties.
	_closed: false,
	_countPosition: 0,
	_countTotal: 0,
	_latency: 200,
	//
	// Public methods.
	increaseCount: function(increment) {
		if (typeof increment == "undefined") {
			increment = 1;
		}

		Skoll.tools.Loading.setCount(Skoll.tools.Loading._countPosition + increment);
	},
	setCount: function(count) {
		if (!Skoll.tools.Loading._closed && Skoll.tools.Loading._countTotal > 0 && count <= Skoll.tools.Loading._countTotal) {
			Skoll.tools.Loading._countPosition = count;
			Skoll.tools.Loading._setCountText();
		} else {
			Skoll.tools.log("Skoll.tools.Loading.setCount(): Count is at its limit");
		}
	},
	setLatency: function(latency) {
		Skoll.tools.Loading._latency = latency;
	},
	setCountTotal: function(total) {
		if (!Skoll.tools.Loading._closed && Skoll.tools.Loading._countTotal > 0 && total > 0) {
			Skoll.tools.Loading._countTotal = total;
			Skoll.tools.Loading._setCountText();
		}
	},
	start: function(startDelay) {
		Skoll.tools.Loading.stop();

		var delay = Skoll.tools.Loading._latency;

		if (typeof startDelay !== "undefined") {
			delay = startDelay;
		}

		Skoll.tools.Loading._closed = false;
		setTimeout(function() {
			Skoll.tools.Loading._createScreen(false);
		}, delay);
	},
	startCount: function(total) {
		Skoll.tools.Loading.stop();
		Skoll.tools.Loading._closed = false;
		Skoll.tools.Loading._countTotal = total;
		Skoll.tools.Loading.setCount(0);
		Skoll.tools.Loading._createScreen(true);
	},
	stop: function() {
		$("#LoadingScreen").remove();
		Skoll.tools.Loading._countTotal = 0;
		Skoll.tools.Loading._closed = true;
	},
	//
	// Protected methods.
	_createScreen: function(hasCount) {
		if (!Skoll.tools.Loading._closed) {
			var countHTML = hasCount && Skoll.tools.Loading._countTotal > 0 ? '<span class="Countdown"></span>' : '';
			$("body").append('<div id="LoadingScreen"><div class="MessageFrame"><img src="' + SKIN_URI + '/images/wcomix-loading-256px.gif" alt="Loading..."/>' + countHTML + '</div></div>');
			Skoll.tools.Loading._setCountText();
		}
	},
	_setCountText: function() {
		if (!Skoll.tools.Loading._closed) {
			$("#LoadingScreen .Countdown").text(Skoll.tools.Loading._countPosition + '/' + Skoll.tools.Loading._countTotal);
		}
	}
};// 'js/skoll.tools.loading.js' END
// 'js/skoll.tools.shortcuts.js' START:
/**
 * @file skoll.tools.shortcuts.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll skin short-cuts manager.
 */
Skoll.tools.ShortCuts = {
	//
	// Protected properties.
	_clicks: [],
	_enabled: false,
	_triggers: [],
	//
	// Public methods.
	add: function(key, callback) {
		Skoll.tools.ShortCuts._triggers[key] = callback;
	},
	addClick: function(key, selector) {
		Skoll.tools.ShortCuts._clicks[key] = selector;
	},
	disable: function() {
		Skoll.tools.ShortCuts._enabled = false;
		Skoll.tools.log("Short cuts disabled");
	},
	enable: function() {
		Skoll.tools.ShortCuts._enabled = true;
		Skoll.tools.log("Short cuts enabled");
	},
	remove: function(key) {
		if (Skoll.tools.ShortCuts._clicks[key]) {
			delete Skoll.tools.ShortCuts._clicks[key];
		}
		if (Skoll.tools.ShortCuts._triggers[key]) {
			delete Skoll.tools.ShortCuts._triggers[key];
		}
	},
	reset: function() {
		Skoll.tools.ShortCuts._clicks = [];
		Skoll.tools.ShortCuts._enabled = false;
		Skoll.tools.ShortCuts._triggers = [];
	},
	//
	// Protected methods.
	_keyEventToText: function(event) {
		var key = (event.ctrlKey ? 'CTRL+' : '') + (event.altKey ? 'ALT+' : '') + (event.shiftKey ? 'SHIFT+' : ''), keyCode = event.keyCode, code;

		if (keyCode >= 96 && keyCode <= 105) {
			keyCode = keyCode - 48;
			code = String.fromCharCode(keyCode);
		} else {
			switch (event.keyCode) {
				case 27:
					code = "ESC";
					break;
				case 106:
					code = "*";
					break;
				case 107:
					code = "+";
					break;
				case 109:
					code = "-";
					break;
				case 110:
					code = ".";
					break;
				case 111:
					code = "/";
					break;
				default:
					code = String.fromCharCode(event.keyCode);
					break;
			}
		}

		return key + code;
	},
	_trigger: function(event) {
		if (Skoll.tools.ShortCuts._enabled) {
			Skoll.tools.log(Skoll.tools.ShortCuts._keyEventToText(event));
			var key = Skoll.tools.ShortCuts._keyEventToText(event);

			if (typeof Skoll.tools.ShortCuts._clicks[key] != "undefined") {
				$(Skoll.tools.ShortCuts._clicks[key]).trigger("click");
				Skoll.tools.preventDefault(event);
			} else if (typeof Skoll.tools.ShortCuts._triggers[key] != "undefined") {
				Skoll.tools.ShortCuts._triggers[key](key, event);
				Skoll.tools.preventDefault(event);
			}
		}
	}
};

$(document).ready(function() {
	$(".avoid-shortcuts").focusin(Skoll.tools.ShortCuts.disable).focusout(Skoll.tools.ShortCuts.enable);
});
// 'js/skoll.tools.shortcuts.js' END
// 'js/skoll.tools.autocomplete.js' START:
/**
 * @file skoll.tools.autocomplete.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll loading screen.
 */
Skoll.tools.Autocomplete = {
	//
	// Protected Properties.
	_autoTransID: 0,
	//
	// Public methods.
	bindClasses: function() {
		$("input[type='text'].Skoll-autocomplete-collections").each(function() {
			Skoll.tools.Autocomplete.bindForCollections(this);
		});
		$("input[type='text'].Skoll-autocomplete-directories").each(function() {
			Skoll.tools.Autocomplete.bindForDirectories(this);
		});
		$("input[type='text'].Skoll-autocomplete-searches").each(function() {
			Skoll.tools.Autocomplete.bindForSearches(this);
		});
		$("input[type='text'].Skoll-autocomplete-tags").each(function() {
			Skoll.tools.log($(this).attr("id"));
			Skoll.tools.Autocomplete.bindForTags(this);
		});
	},
	bindForCollections: function(obj) {

	},
	bindForDirectories: function(obj) {
		$(obj).bind("keydown", function(event) {
			if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) {
				Skoll.tools.preventDefault(event);
			}
		}).autocomplete({
			source: function(request, response) {
				var pattern = request.term.split(/,\s*/).pop();
				if (pattern.length == 0) {
					return false;
				}

				Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): Asking for pattern '" + pattern + "'");
				Skoll.tools.Autocomplete._autoTransID++;
				Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): Sending transaction '" + Skoll.tools.Autocomplete._autoTransID + "'");
				$.ajax({
					dataType: "json",
					url: "service.php?service=directories:pattern&group=" + GROUP_ID + "&pattern=" + pattern + "&transaction=" + Skoll.tools.Autocomplete._autoTransID,
					type: "GET",
					data: {
					},
					success: function(data) {
						Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): Receiving transaction '" + data.transaction + "'");
						if (data.transaction == Skoll.tools.Autocomplete._autoTransID) {
							Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): Setting results from transaction '" + data.transaction + "'");
							if (data.status) {
								var availableDirs = Array();
								data.data.forEach(function(item) {
									availableDirs.push(item.name);
								});
								Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): directory received: '" + availableDirs.length + "'");
								response(availableDirs);
							} else {
								Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): [" + data.error.code + "] " + data.error.message);
							}
						}
					},
					error: function(data) {
						Skoll.tools.log("Skoll.tools.Autocomplete.bindForDirectories(): Error " + data);
					}
				});
			},
			focus: function() {
				// prevent value inserted on focus
				return false;
			},
			select: function(event, ui) {
				var terms = this.value.split(/,\s*/);
				// remove the current input
				terms.pop();
				// add the selected item
				terms.push(ui.item.value);
				// add placeholder to get the comma-and-space at the end
				terms.push("");
				this.value = terms.join(", ");
				return false;
			}
		});
	},
	bindForSearches: function(obj) {

	},
	bindForTags: function(obj) {
		$(obj).bind("keydown", function(event) {
			if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) {
				Skoll.tools.preventDefault(event);
			}
		}).autocomplete({
			source: function(request, response) {
				var pattern = request.term.split(/,\s*/).pop();
				if (pattern.length == 0) {
					return false;
				}

				Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): Asking for pattern '" + pattern + "'");
				Skoll.tools.Autocomplete._autoTransID++;
				Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): Sending transaction '" + Skoll.tools.Autocomplete._autoTransID + "'");
				$.ajax({
					dataType: "json",
					url: "service.php?service=tags:pattern&group=" + GROUP_ID + "&pattern=" + pattern + "&transaction=" + Skoll.tools.Autocomplete._autoTransID,
					type: "GET",
					data: {
					},
					success: function(data) {
						Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): Receiving transaction '" + data.transaction + "'");
						if (data.transaction == Skoll.tools.Autocomplete._autoTransID) {
							Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): Setting results from transaction '" + data.transaction + "'");
							if (data.status) {
								var availableTags = Array();
								data.data.forEach(function(item) {
									availableTags.push(item.name);
								});
								Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): tags received: '" + availableTags.length + "'");
								response(availableTags);
							} else {
								Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): [" + data.error.code + "] " + data.error.message);
							}
						}
					},
					error: function(data) {
						Skoll.tools.log("Skoll.tools.Autocomplete.bindForTags(): Error " + data);
					}
				});
			},
			focus: function() {
				// prevent value inserted on focus
				return false;
			},
			select: function(event, ui) {
				var terms = this.value.split(/,\s*/);
				// remove the current input
				terms.pop();
				// add the selected item
				terms.push(ui.item.value);
				// add placeholder to get the comma-and-space at the end
				terms.push("");
				this.value = terms.join(", ");
				return false;
			}
		});
	}
};
$(document).ready(function() {
	Skoll.tools.Autocomplete.bindClasses();
});// 'js/skoll.tools.autocomplete.js' END
// 'js/skoll.tools.tooltips.js' START:
/**
 * @file skoll.tools.tooltips.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll skin modal windows manager.
 */
Skoll.tools.ToolTips = {
	//
	// Protected properties.
	_x: 0,
	_y: 0,
	//
	// Public methods.
	close: function() {
		$("#SkollToolTip").addClass("Bermuda");
	},
	open: function(html) {
		if ($("#SkollToolTip").length == 0) {
			$("body").append('<div id="SkollToolTip" class="ToolTip Bermuda"></div>');

			$("body").on("click", function(e) {
				if (!$("#SkollToolTip").is(e.target) && $("#SkollToolTip").has(e.target).length === 0) {
					Skoll.tools.ToolTips.close();
				}
			});
		}

		$("#SkollToolTip").html(html);
		$("#SkollToolTip").removeClass("Bermuda");
		Skoll.tools.ToolTips._setCssPostion();
	},
	openFromUrl: function(url) {
		Skoll.tools.log("ToolTips.openFromUrl(): url '" + url + "'");

		$.ajax({
			url: url,
			success: function(html) {
				Skoll.tools.log("ToolTips.openFromUrl(): opening tooltip");
				Skoll.tools.ToolTips.open(html);
			}
		});
	},
	setPostion: function(x, y) {
		Skoll.tools.ToolTips._x = x;
		Skoll.tools.ToolTips._y = y;

		if ($("#SkollToolTip").length != 0 && !$("#SkollToolTip").hasClass("Bermuda")) {
			Skoll.tools.ToolTips._setCssPostion();
		}
	},
	//
	// Protected methods.
	_setCssPostion: function() {
		$("#SkollToolTip").css({
			left: Skoll.tools.ToolTips._x + "px",
			top: Skoll.tools.ToolTips._y + "px"
		});
	}
};// 'js/skoll.tools.tooltips.js' END
// 'js/skoll.tools.modalwindow.js' START:
/**
 * @file skoll.tools.modalwindow.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll skin modal windows manager.
 */
Skoll.tools.ModalWindow = {
	//
	// Protected properties.
	_closeListeners: [],
	//
	// Public methods.
	addCloseListener: function(listener) {
		Skoll.tools.ModalWindow._closeListeners.push(listener);
	},
	closeModal: function() {
		Skoll.tools.preventDefault();
		$("#SkollModalDialog").dialog("close");
	},
	modal: function(config) {
		if ($("#SkollModalDialog").dialog("isOpen")) {
			$("#SkollModalDialog").dialog(config);
		}
	},
	openModal: function(url, callback) {
		Skoll.tools.log("ModalWindow.openModal(): Url: " + url);
		Skoll.tools.Loading.start(0);

		$.ajax({
			url: url + "&nolayout",
			type: "GET",
			success: function(data) {
				Skoll.tools.ModalWindow.openSimpleModal(data, callback);

				Skoll.tools.Loading.stop();
			},
			error: function(data) {
				Skoll.tools.log("ModalWindow.openModal(): Unable to open ': " + url + "'");
				Skoll.tools.log(data);

				Skoll.tools.Loading.stop();
			}
		});
	},
	openSimpleModal: function(data, callback) {
		if (typeof callback != "undefined") {
			Skoll.tools.ModalWindow.addCloseListener(callback);
		}
		$("body").append('<div id="SkollModalDialog"></div>');

		$("#SkollModalDialog").html(data);
		if ($("#SkollModalDialog").hasClass("Bermuda")) {
			$("#SkollModalDialog").removeClass("Bermuda");
		}

		$("#SkollModalDialog").dialog({
			close: function(event) {
				Skoll.tools.ModalWindow._fireCloseListeners();
				$(this).dialog("destroy");
				$("#SkollModalDialog").remove();
			},
			closeOnEscape: true,
			modal: true,
			width: "auto"
		});


		$("[modal-title]").each(function() {
			Skoll.tools.ModalWindow.modal({
				title: $(this).attr("modal-title")
			});
		});

		setTimeout(function() {
			$("#SkollModalDialog").dialog({
				position: "center"
			});
		}, 200);
		setTimeout(function() {
			$("#SkollModalDialog").dialog({
				position: "center"
			});
		}, 1000);
	},
	//
	// Protected methods.
	_fireCloseListeners: function() {
		Skoll.tools.ModalWindow._closeListeners.forEach(function(listener) {
			var type = typeof listener;

			if (type == "function") {
				listener();
			} else if (type == "string") {
				Skoll.tools.log(listener);
			}

			Skoll.tools.ModalWindow._closeListeners.splice(Skoll.tools.ModalWindow._closeListeners.indexOf(listener), 1);
		});
	}
};// 'js/skoll.tools.modalwindow.js' END
// 'js/skoll.tools.confirmwindow.js' START:
/**
 * @file skoll.tools.confirmwindow.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

/**
 * Skoll skin modal windows manager.
 */
Skoll.tools.ConfirmWindow = {
	//
	// Protected properties.
//	_closeListeners: [],
	//
	// Public methods.
//	addCloseListener: function(listener) {
//		Skoll.tools.ConfirmWindow._closeListeners.push(listener);
//	},
	closeConfirm: function() {
		Skoll.tools.preventDefault();
		$("#SkollConfirmDialog").dialog("close");
	},
	modal: function(config) {
		if ($("#SkollConfirmDialog").dialog("isOpen")) {
			$("#SkollConfirmDialog").dialog(config);
		}
	},
	openConfirm: function(url, yesCallback, noCallback) {
		Skoll.tools.log("ConfirmWindow.openConfirm(): Url: " + url);
		$.ajax({
			url: url + "&nolayout",
			type: "GET",
			success: function(data) {
				Skoll.tools.ConfirmWindow.openSimpleConfirm(data, yesCallback, noCallback);
			},
			error: function(data) {
				Skoll.tools.log("ConfirmWindow.openConfirm(): Unable to open ': " + url + "'");
				Skoll.tools.log(data);
			}
		});
	},
	openSimpleConfirm: function(message, yesCallback, noCallback) {
		$("body").append('<div id="SkollConfirmDialog"></div>');

		$("#SkollConfirmDialog").html(message);
		if ($("#SkollConfirmDialog").hasClass("Bermuda")) {
			$("#SkollConfirmDialog").removeClass("Bermuda");
		}

		$("#SkollConfirmDialog").dialog({
			close: function(event) {
//				Skoll.tools.ConfirmWindow._fireCloseListeners();
				$(this).dialog("destroy");
				$("#SkollConfirmDialog").remove();
			},
			buttons: {
				No: function() {
					if (typeof noCallback == "function") {
						noCallback();
					} else {
						Skoll.tools.log("There's no callback for button 'no'");
					}
					$(this).dialog("close");
				},
				Yes: function() {
					if (typeof yesCallback == "function") {
						yesCallback();
					} else {
						Skoll.tools.log("There's no callback for button 'yes'");
					}
					$(this).dialog("close");
				}
			},
			closeOnEscape: false,
			modal: true,
			width: "auto"
		});


		$("[modal-title]").each(function() {
			Skoll.tools.ConfirmWindow.modal({
				title: $(this).attr("modal-title")
			});
		});

		setTimeout(function() {
			$("#SkollConfirmDialog").dialog({
				position: "center"
			});
		}, 200);
		setTimeout(function() {
			$("#SkollConfirmDialog").dialog({
				position: "center"
			});
		}, 1000);
	}
//	,
	//
	// Protected methods.
//	_fireCloseListeners: function() {
//		Skoll.tools.ConfirmWindow._closeListeners.forEach(function(listener) {
//			var type = typeof listener;
//
//			if (type == "function") {
//				listener();
//			} else if (type == "string") {
//				Skoll.tools.log(listener);
//			}
//
//			Skoll.tools.ConfirmWindow._closeListeners.splice(Skoll.tools.ConfirmWindow._closeListeners.indexOf(listener), 1);
//		});
//	}
};// 'js/skoll.tools.confirmwindow.js' END
// 'js/skoll.js' START:
/**
 * @file skoll.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

$(document).ready(function() {
	$(document).keyup(function(event) {
		Skoll.tools.ShortCuts._trigger(event);
	});

	if (READ_ONLY) {
		$("body").append('<div class="SystemAlert">Read Only Mode: Active</div>');
	}
});
// 'js/skoll.js' END
// 'js/skoll.actions.topbar.js' START:
/**
 * @file skoll.actions.topbar.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.topbar = {
	//
	// Protected properties.
	//
	// Public methods.
	closeMenues: function() {
		$("#TopBarMenu").remove();
	},
	openHome: function(button) {
		Skoll.tools.preventDefault();

		Skoll.actions.topbar.closeMenues();
		Skoll.tools.reloadHome();
	},
	openLeftMenu: function(code, button) {
		Skoll.tools.Loading.start();

		Skoll.tools.preventDefault();

		Skoll.actions.topbar.closeMenues();

		var x = $(button).offset().left;
		var y = $(button).height();
		$.ajax({
			url: "?action=menu&code=" + code + "&nolayout&group=" + GROUP_ID + Skoll.tools.extraUrlParams(),
			success: function(data) {
				Skoll.actions.topbar._openMenu(data, x, y);
				Skoll.tools.Loading.stop();
			},
			error: function(data) {
			}
		});

		return false;
	},
	openRightUser: function(code, button) {
		Skoll.tools.Loading.start();

		Skoll.tools.preventDefault();

		Skoll.actions.topbar.closeMenues();

		var x = $(button).offset().left;
		var y = $(button).height();
		$.ajax({
			url: "?action=menu&code=" + code + "&nolayout&group=" + GROUP_ID + Skoll.tools.extraUrlParams(),
			success: function(data) {
				Skoll.actions.topbar._openMenu(data, x, y);
				Skoll.tools.Loading.stop();
			},
			error: function(data) {
			}
		});

		return false;
	},
	setPath: function(path) {
		$("#TopBarPath").text(path);
	},
	//
	// Protected methods.
	_bindButtons: function() {
		$(document).on("click", ".wc-topbar-home", function() {
			Skoll.actions.topbar.openHome($(this));
		});
		$(document).on("click", ".wc-topbar-menu-main", function() {
			Skoll.actions.topbar.openLeftMenu("main", $(this));
		});
		$(document).on("click", ".wc-topbar-menu-shortcuts", function() {
			Skoll.actions.topbar.openLeftMenu("shortcuts", $(this));
		});
		$(document).on("click", ".wc-topbar-menu-user", function() {
			Skoll.actions.topbar.openRightUser("user", $(this));
		});
		$(document).on("click", ".wc-topbar-menu-admin", function() {
			Skoll.actions.topbar.openLeftMenu("admin", $(this));
		});
	},
	_openMenu: function(data, x, y) {
		$("#TopBar").append('<div id="TopBarMenu"></div>');

		$("#TopBarMenu").html(data);

		var menu = $("#TopBarMenu .Menu");
		$(menu).css({
			position: "absolute",
			top: y + "px",
			left: x + "px"
		});

		var menuWidth = 0;
//		var menuHeight = 0;
		menu.each(function() {
			menuWidth = this.clientWidth;
//			menuHeight = this.clientHeight;
		});

		var changeCss = false;
		var changedCss = {};
		if ((x + menuWidth) > $(window).width()) {
			changedCss.position = "absolute";
			changedCss.top = y + "px";
			changedCss.left = ($(window).width() - menuWidth) + "px";

			changeCss = true;
		}
//		if ((y + menuHeight) > $(window).height()) {
//			changedCss.position = "fixed";
//
//			changeCss = true;
//		}

		if (changeCss) {
			$(menu).css(changedCss);
		}
	}
};

$(document).ready(function() {
	Skoll.actions.topbar._bindButtons();
	$("body").on("click", function(e) {
		Skoll.actions.topbar.closeMenues();
	});
});// 'js/skoll.actions.topbar.js' END
// 'js/skoll.actions.menu.user.js' START:
/**
 * @file skoll.actions.menu.user.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.menu.user = {
	//
	// Protected properties.
	//
	// Public methods.
	login: function() {
		Skoll.tools.log("Skoll.actions.menu.user.login()");
		Skoll.tools.ModalWindow.openModal("?action=content:user:login" + Skoll.tools.extraUrlParams(), function() {
		});
	},
	logout: function() {
		Skoll.tools.log("Skoll.actions.menu.user.logout()");
		Skoll.actions.content.user.logout();
	},
	switchMobile: function() {
		Skoll.tools.log("Skoll.actions.menu.user.switchMobile()");
	},
	switchGroup: function() {
		Skoll.tools.log("Skoll.actions.menu.user.switchGroup()");
		Skoll.tools.ModalWindow.openModal("?action=content:switchgroup&group=" + GROUP_ID + Skoll.tools.extraUrlParams(), function() {
		});
	},
	//
	// Protected methods.
	_bindButtons: function() {
		$(document).on("click", ".wc-usermenu-switchgroup", function() {
			Skoll.actions.menu.user.switchGroup();
		});
		$(document).on("click", ".wc-usermenu-mobile", function() {
			Skoll.actions.menu.user.switchMobile();
		});
		$(document).on("click", ".wc-usermenu-logout", function() {
			Skoll.actions.menu.user.logout();
		});
		$(document).on("click", ".wc-usermenu-login", function() {
			Skoll.actions.menu.user.login();
		});
	}
};

$(document).ready(function() {
	Skoll.actions.menu.user._bindButtons();
});// 'js/skoll.actions.menu.user.js' END
// 'js/skoll.actions.httperror.js' START:
/**
 * @file skoll.actions.httperror.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.httperror = {
	//
	// Protected properties.
	//
	// Public methods.
	cleanActionDebugers: function() {
		if (typeof Skoll.config.debug != "undefined" && !Skoll.config.debug) {
			$(".ActionDebuger").each(function() {
				$(this).replaceWith($(this).html());
			});
		}
	}
};

$(document).ready(function() {
	Skoll.configLeeches.push(Skoll.actions.httperror.cleanActionDebugers);
	Skoll.configLeechesRun();
});
// 'js/skoll.actions.httperror.js' END
// 'js/skoll.actions.info.edittagsof.js' START:
/**
 * @file skoll.actions.info.edittagsof.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.info.edittagsof = {
	//
	// Public methods.
	removeTagFrom: function(tag, itemType, item) {
//		Skoll.tools.Loading.start(0);
//
		var service = "tags:remove:";
		var what = "";
		switch (itemType) {
			case "CX":
				what = "comic";
				break;
			case "IM":
				what = "image";
				break;
		}
		var serviceUrl = "service.php?service=" + service + what + "&group=" + GROUP_ID + "&" + what + "=" + item + Skoll.tools.extraUrlParams();

		$.ajax({
			dataType: "json",
			url: serviceUrl,
			type: "POST",
			data: {
				params: JSON.stringify({
					list: [tag]
				})
			},
			success: function(data) {
				if (data.status) {
					Skoll.tools.log("Tags settings success");
					$("#EditTagsOf_TagsBox").wcGetDelayedReload();
//					Skoll.tools.Loading.stop();
				} else {
					Skoll.tools.log("Tags settings error: [" + data.error.code + "] " + data.error.message);
//					Skoll.tools.Loading.stop();
				}
			},
			error: function(data) {
				Skoll.tools.log("Tags settings error: " + data);
//				Skoll.tools.Loading.stop();
			}
		});
	},
	sendTags: function(form, event) {
		Skoll.tools.preventDefault(event);

		var what = $(form).find("#edituriname").val();
		var id = $(form).find("#editid").val();
		var service = "tags:add:" + what;
		var tags = $(form).find("#editnewtags").val().split(",");

		if ($(form).find("#editmode").val() == "REMOVE") {
			service = "tags:remove:comic";
		}

		var serviceUrl = "service.php?service=" + service + "&group=" + GROUP_ID + "&" + what + "=" + id + Skoll.tools.extraUrlParams();
		Skoll.tools.log("Skoll.actions.info.edittagsof.sendTags(): URL: " + serviceUrl);

		$(form).find("#editnewtags").val("");
		$(form).find("#EditTagsOf_TagsBox").append("loading...");

		$(form).find("#editnewtags").val("");
		$.ajax({
			dataType: "json",
			url: serviceUrl,
			type: "POST",
			data: {
				params: JSON.stringify({
					list: tags
				})
			},
			success: function(data) {
				if (data.status) {
					Skoll.tools.log("Tags settings success");
					$(form).find("#EditTagsOf_TagsBox").wcGetDelayedReload();
				} else {
					Skoll.tools.log("Tags settings error: [" + data.error.code + "] " + data.error.message);
				}
			},
			error: function(data) {
				Skoll.tools.log("Tags settings error: " + data);
			}
		});
	}
}
$(document).ready(function() {
	$(document).on("click", ".SkollMethod-RemoveTag", function(event) {
		Skoll.tools.preventDefault(event);
		var info = $.parseJSON($(this).attr("skollinfo"));
		Skoll.actions.info.edittagsof.removeTagFrom(info.tag, info.itemType, info.item);
		$(this).remove();
	});
});// 'js/skoll.actions.info.edittagsof.js' END
// 'js/skoll.actions.info.tagsof.js' START:
/**
 * @file skoll.actions.info.tagsof.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.info.tagsof = {
	//
	// Protected properties.
	_triggerEditTagsEnabled: false,
	//
	// Public methods
	enableTriggerEditTags: function() {
		Skoll.actions.info.tagsof._triggerEditTagsEnabled = true;
	},
	triggerEditTags: function(what, uriWhat, id, name, box) {
		if (Skoll.actions.info.tagsof._triggerEditTagsEnabled) {
			Skoll.tools.ModalWindow.addCloseListener(function() {
				$(box).wcGetDelayedReload("&resetcache");
				Skoll.tools.ShortCuts.enable();
			});
			Skoll.tools.ModalWindow.openModal("?action=info:edittagsof&group=" + GROUP_ID + "&" + uriWhat + "=" + id + Skoll.tools.extraUrlParams());
			Skoll.tools.ModalWindow.modal({
				title: what + ": " + name
			});
		}
	}
}// 'js/skoll.actions.info.tagsof.js' END
// 'js/skoll.actions.content.comic.js' START:
/**
 * @file skoll.actions.content.comic.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.comic = {
	//
	// Protected variables.
	_isRead: null,
	_shortcutsButtons: {
		F: "img.imgfirst",
		C: "img.imgprev5",
		Z: "img.imgprev",
		A: "img.imgcurrent",
		X: "img.imgnext",
		V: "img.imgnext5",
		L: "img.imglast",
		T: "#TagButton"//,		R: "#ComicPersonalRead"
	},
	_shortcutsRating: {
		"1": 1,
		"2": 2,
		"3": 3,
		"4": 4,
		"5": 5,
		"6": 6,
		"7": 7,
		"8": 8,
		"9": 9,
		"0": 10
	},
	//
	// Public methods.
	addShortCuts: function() {
		Skoll.tools.ShortCuts.enable();
		for (var key in Skoll.actions.content.comic._shortcutsButtons) {
			Skoll.tools.ShortCuts.addClick(key, Skoll.actions.content.comic._shortcutsButtons[key]);
		}
		for (var key in Skoll.actions.content.comic._shortcutsRating) {
			Skoll.tools.ShortCuts.add(key, function(key, event) {
				Skoll.actions.content.comic.changeRate(event, Skoll.actions.content.comic._shortcutsRating[key]);
			});
		}
	},
	changeRate: function(event, value) {
		Skoll.tools.preventDefault(event);
//		Skoll.tools.Loading.start();

		$("#ComicPersonalRate").text(wcomix.lang.translate("message_loading___"));

		$.ajax({
			dataType: "json",
			url: "service.php?service=readrate:rate:comic&comic=" + COMIC_ID + "&group=" + GROUP_ID + "",
			type: "POST",
			data: {
				params: JSON.stringify({
					rate: value
				})
			},
			success: function(response) {
				if (typeof response.status !== "undefined" && response.status) {
					Skoll.tools.Baloon.message(wcomix.lang.translate("message_you_rated_as_of", {
						name: COMIC_NAME,
						count: value,
						total: 10
					}));

					Skoll.actions.content.comic.loadReadRate();
//
//					for (var shortcut in Skoll.actions.content.comic._shortcutsRating) {
//						shortcut.remove(key);
//					}
				} else {
					Skoll.tools.log(response);
				}

//				Skoll.tools.Loading.stop();
			},
			error: function(response) {
				Skoll.tools.log(response);
//				Skoll.tools.Loading.stop();
			}
		});
	},
	loadImage: function(linkObj) {
		Skoll.tools.Loading.start();
		var basicLoad = false;
		var urlLink = $(linkObj).attr("href");
		var link = urlLink + "&nolayout&format=json";
		Skoll.tools.log("Skoll.actions.content.comic.loadImage(): Loading '" + link + "'");
		window.history.pushState("", "", urlLink);
		$.ajax({
			url: link,
			dataType: "json",
			success: function(data) {
				Skoll.actions.content.comic._loadImage(data);
				Skoll.tools.Loading.stop();
			},
			error: function(data) {
				Skoll.tools.Loading.stop();
			}
		});
		if (!basicLoad) {
			Skoll.tools.preventDefault();
		}
	},
	loadReadRate: function() {
		$.ajax({
			url: "service.php?service=readrate:get:comic&group=" + GROUP_ID + "&comic=" + COMIC_ID,
			type: "GET",
			dataType: "json",
			success: function(response) {
				if (typeof response.status !== "undefined" && response.status) {
					var text = wcomix.lang.translate("text_counts_of_total", {
						total: 10,
						count: response.data.global.rate
					});
					text += " (";
					text += wcomix.lang.translate("text_count_votes", {
						count: response.data.global.votes
					});
					text += ")";

					$("#ComicGlobalRate").text(text);

					text = "";
					if (response.data.personal.pending) {
						text = wcomix.lang.translate("label_user_rate_pending_comic");
					} else {
						text = wcomix.lang.translate("text_counts_of_total", {
							total: 10,
							count: response.data.personal.rate
						});
					}
					$("#ComicPersonalRate").text(text);

					Skoll.actions.content.comic._isRead = response.data.personal.read;
					if (Skoll.actions.content.comic._isRead) {
						$("#ComicPersonalRead").text(wcomix.lang.translate("label_read"));
					} else {
						$("#ComicPersonalRead").text(wcomix.lang.translate("label_unread"));
					}
				} else {
					Skoll.tools.log(response);
				}
			},
			error: function(response) {
				Skoll.tools.log(response);
			}
		});
	},
	shortCutsHelp: function() {
		Skoll.tools.preventDefault();
		Skoll.tools.ModalWindow.openSimpleModal($("#ShortcutsHelp").html());
	},
	//
	// Protected methods.
	_binds: function() {
		$("#ComicPersonalRead").on("click", function(event) {
			if (Skoll.actions.content.comic._isRead !== null) {
				Skoll.tools.preventDefault(event);
//				Skoll.tools.Loading.start();

				var currentStatus = Skoll.actions.content.comic._isRead;
				Skoll.actions.content.comic._isRead = null;

				$("#ComicPersonalRead").text(wcomix.lang.translate("message_loading___"));


				$.ajax({
					dataType: "json",
					url: "service.php?service=readrate:read:comic&comic=" + COMIC_ID + "&group=" + GROUP_ID + "",
					type: "POST",
					data: {
						params: JSON.stringify({
							read: !currentStatus
						})
					},
					success: function(response) {
						if (typeof response.status !== "undefined" && response.status) {
							Skoll.tools.Baloon.message(wcomix.lang.translate("message_you_marked_as", {
								name: COMIC_NAME,
								status: wcomix.lang.translate(currentStatus ? "label_unread" : "label_read")
							}));

							Skoll.actions.content.comic.loadReadRate();
						} else {
							Skoll.tools.log(response);
						}

//						Skoll.tools.Loading.stop();
					},
					error: function(response) {
						Skoll.tools.log(response);
//						Skoll.tools.Loading.stop();
					}
				});
			}
		});
	},
	_loadImage: function(data) {
		Skoll.tools.log("Skoll.actions.content.comic._loadImage(): Filling with results");
		$("#FullImage").attr("src", data.imgmain);
		$("a.lnkfirst,buttom.lnkfirst").attr("href", data.lnkfirst.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("a.lnkprev5,buttom.lnkprev5").attr("href", data.lnkprev5.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("a.lnkprev,buttom.lnkprev").attr("href", data.lnkprev.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("a.linktable,buttom.linktable").attr("href", data.linktable.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("a.lnknext,buttom.lnknext").attr("href", data.lnknext.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("a.lnknext5,buttom.lnknext5").attr("href", data.lnknext5.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("a.lnklast,buttom.lnklast").attr("href", data.lnklast.replace(/&nolayout([^&]*)&format([^&]*)/, ""));
		$("img.imglast").attr("src", data.imglast);
		$("img.imgprev5").attr("src", data.imgprev5);
		$("img.imgprev").attr("src", data.imgprev);
		$("img.imgcurrent").attr("src", data.imgcurrent);
		$("img.imgnext").attr("src", data.imgnext);
		$("img.imgnext5").attr("src", data.imgnext5);
		$("img.imglast").attr("src", data.imglast);
		$("span.imagename").text(data.info_img_name);
		$("#ComicPosition").html(wcomix.lang.translate("text_counts_of_total", {
			count: data.info_number,
			total: data.info_number_of
		}));
		$("span.imagename").html(data.info_img_name);
		Skoll.actions.topbar.setPath(data.PATH);
		window.scrollTo(0, 0);
	}
};

$(document).ready(function() {
	Skoll.actions.content.comic._binds();
});// 'js/skoll.actions.content.comic.js' END
// 'js/skoll.actions.content.image.js' START:
/**
 * @file skoll.actions.content.image.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.image = {
	//
	// Protected variables.
	_shortcutsButtons: {
		F: "img.imgfirst",
		C: "img.imgprev5",
		Z: "img.imgprev",
		A: "img.imgcurrent",
		X: "img.imgnext",
		V: "img.imgnext5",
		L: "img.imglast",
		T: "#TagButton"//,		R: "#ReadLight"
	},
	_shortcutsRating: {
		"1": 1,
		"2": 2,
		"3": 3,
		"4": 4,
		"5": 5,
		"6": 6,
		"7": 7,
		"8": 8,
		"9": 9,
		"0": 10
	},
	//
	// Public methods.
	addShortCuts: function() {
		Skoll.tools.ShortCuts.enable();
		for (var key in Skoll.actions.content.image._shortcutsButtons) {
			Skoll.tools.ShortCuts.addClick(key, Skoll.actions.content.image._shortcutsButtons[key]);
		}
		for (var key in Skoll.actions.content.image._shortcutsRating) {
			Skoll.tools.ShortCuts.add(key, function(key, event) {
				Skoll.actions.content.image.changeRate(event, Skoll.actions.content.image._shortcutsRating[key]);
			});
		}
	},
	changeRate: function(event, value) {
		Skoll.tools.preventDefault(event);
//		Skoll.tools.Loading.start();

		$("#ImagePersonalRate").text(wcomix.lang.translate("message_loading___"));

		$.ajax({
			dataType: "json",
			url: "service.php?service=readrate:rate:image&image=" + IMAGE_ID + "&group=" + GROUP_ID + "",
			type: "POST",
			data: {
				params: JSON.stringify({
					rate: value
				})
			},
			success: function(response) {
				if (typeof response.status !== "undefined" && response.status) {
					Skoll.tools.Baloon.message(wcomix.lang.translate("message_you_rated_as_of", {
						name: IMAGE_NAME,
						count: value,
						total: 10
					}));

					Skoll.actions.content.image.loadReadRate();
//
//					for (var shortcut in Skoll.actions.content.image._shortcutsRating) {
//						shortcut.remove(key);
//					}
				} else {
					Skoll.tools.log(response);
				}

//				Skoll.tools.Loading.stop();
			},
			error: function(response) {
				Skoll.tools.log(response);
//				Skoll.tools.Loading.stop();
			}
		});
	},
	loadImage: function(linkObj) {
		return true;
	},
	loadReadRate: function() {
		$.ajax({
			url: "service.php?service=readrate:get:image",
			data: {
				group: GROUP_ID,
				image: IMAGE_ID
			},
			dataType: "json",
			success: function(response) {
				console.log(response);
				if (typeof response.status !== "undefined" && response.status) {
					var text = wcomix.lang.translate("text_counts_of_total", {
						total: 10,
						count: response.data.global.rate
					});
					text += " (";
					text += wcomix.lang.translate("text_count_votes", {
						count: response.data.global.votes
					});
					text += ")";

					$("#ImageGlobalRate").text(text);

					$("#ImageGlobalRate").text(text);

					text = "";
					if (response.data.personal.pending) {
						text = wcomix.lang.translate("label_user_rate_pending_image");
					} else {
						text = wcomix.lang.translate("text_counts_of_total", {
							total: 10,
							count: response.data.personal.rate
						});
					}
					$("#ImagePersonalRate").text(text);

					Skoll.actions.content.image._isRead = response.data.personal.read;
					if (Skoll.actions.content.image._isRead) {
						$("#ImagePersonalRead").text(wcomix.lang.translate("label_read"));
					} else {
						$("#ImagePersonalRead").text(wcomix.lang.translate("label_unread"));
					}
				} else {
					Skoll.tools.log(response);
				}
			},
			error: function(response) {
				Skoll.tools.log(response);
			}
		});
	},
	shortCutsHelp: function() {
		Skoll.tools.preventDefault();
		Skoll.tools.ModalWindow.openSimpleModal($("#ShortcutsHelp").html());
	},
	//
	// Protected methods.
	_binds: function() {
		$("#ImagePersonalRead").on("click", function(event) {
			if (Skoll.actions.content.image._isRead !== null) {
				Skoll.tools.preventDefault(event);
//				Skoll.tools.Loading.start();

				var currentStatus = Skoll.actions.content.image._isRead;
				Skoll.actions.content.image._isRead = null;

				$("#ImagePersonalRead").text(wcomix.lang.translate("message_loading___"));


				$.ajax({
					dataType: "json",
					url: "service.php?service=readrate:read:image&image=" + IMAGE_ID + "&group=" + GROUP_ID + "",
					type: "POST",
					data: {
						params: JSON.stringify({
							read: !currentStatus
						})
					},
					success: function(response) {
						if (typeof response.status !== "undefined" && response.status) {
							Skoll.tools.Baloon.message(wcomix.lang.translate("message_you_marked_as", {
								name: IMAGE_NAME,
								status: wcomix.lang.translate(currentStatus ? "label_unread" : "label_read")
							}));

							Skoll.actions.content.image.loadReadRate();
						} else {
							Skoll.tools.log(response);
						}

//						Skoll.tools.Loading.stop();
					},
					error: function(response) {
						Skoll.tools.log(response);
//						Skoll.tools.Loading.stop();
					}
				});
			}
		});
	}
};

$(document).ready(function() {
//	$("input[type=text]").focusin(Skoll.actions.content.image._removeShortCuts).focusout(Skoll.actions.content.image._addShortCuts);
//	$("textarea").focusin(Skoll.actions.content.image._removeShortCuts).focusout(Skoll.actions.content.image._addShortCuts);
	Skoll.actions.content.image._binds();
});
// 'js/skoll.actions.content.image.js' END
// 'js/skoll.actions.content.rules.js' START:
/**
 * @file skoll.actions.content.rules.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.rules = {
	//
	// Protected properties.
	//
	// Public methods.
	createRule: function(form) {
		Skoll.tools.Loading.start(0);
		Skoll.tools.preventDefault();

		var nameInput = $(form).find("#NewRuleName");
		var name = nameInput.val().trim();

		if (name.length > 0) {
			$.ajax({
				type: "POST",
				url: "service.php?service=rules:add:rule&group=" + GROUP_ID,
				data: {
					params: JSON.stringify({
						"name": name
					})
				},
				dataType: "json",
				success: function(data) {
					if (data.status) {
						nameInput.val("");
						window.location.href = "?action=content:rule&group=" + GROUP_ID + "&rule=" + data.data.id + Skoll.tools.extraUrlParams();
					} else {
						Skoll.tools.log("Error: [" + data.error.code + "] " + data.error.message);
						alert("Failed: " + data.error.message);
						Skoll.tools.Loading.stop();
					}
					nameInput.focus();
				},
				error: function(data) {
					alert(data);
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			nameInput.focus();
			alert("You must enter a rule name");
			Skoll.tools.Loading.stop();
		}
	},
	removeRule: function(ruleId, ruleName) {
		Skoll.tools.preventDefault();
		Skoll.tools.ConfirmWindow.openSimpleConfirm(
			"Are you sure you want to remove rule '" + ruleName + "'?",
			function() {
				Skoll.tools.Loading.start(0);
				$.ajax({
					type: "POST",
					url: "service.php?service=rules:remove:rule&group=" + GROUP_ID + "&rule=" + ruleId,
					data: {
						params: JSON.stringify({})
					},
					dataType: "json",
					success: function(data) {
						if (data.status) {
							Skoll.tools.reload();
						} else {
							Skoll.tools.log("Error: [" + data.error.code + "] " + data.error.message);
							alert("Failed: " + data.error.message);
							Skoll.tools.Loading.stop();
						}
						nameInput.focus();
					},
					error: function(data) {
						alert(data);
						Skoll.tools.Loading.stop();
					}
				});
			}
		);
	}
	//
	// Protected methods.
};// 'js/skoll.actions.content.rules.js' END
// 'js/skoll.actions.content.rule.js' START:
/**
 * @file skoll.actions.content.rule.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.rule = {
	//
	// Protected properties.
	//
	// Public methods.
	createAction: function(form, ruleId) {
		Skoll.tools.preventDefault();

		var typeSelect = $(form).find("#NewActionType");
		var typeCreator = typeSelect.val().trim();

		if (typeCreator.length > 0) {
			window.location.href = "?action=" + typeCreator + "&group=" + GROUP_ID + "&rule=" + ruleId + Skoll.tools.extraUrlParams();
		} else {
			typeSelect.focus();
			alert("You must select a rule action type");
			Skoll.tools.Loading.stop();
		}
	},
	removeAction: function(ruleId, actionId, actionName) {
		Skoll.tools.preventDefault();
		Skoll.tools.ConfirmWindow.openSimpleConfirm(
			"Are you sure you want to remove rule action '" + actionName + "'?",
			function() {
				Skoll.tools.Loading.start(0);
				$.ajax({
					type: "POST",
					url: "service.php?service=rules:remove:action&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + actionId,
					data: {
						params: JSON.stringify({})
					},
					dataType: "json",
					success: function(data) {
						if (data.status) {
							Skoll.tools.reload();
						} else {
							Skoll.tools.log("Error: [" + data.error.code + "] " + data.error.message);
							alert("Failed: " + data.error.message);
							Skoll.tools.Loading.stop();
						}
						typeSelect.focus();
					},
					error: function(data) {
						alert(data);
						Skoll.tools.Loading.stop();
					}
				});
			}
		);
	}
	//
	// Protected methods.
};// 'js/skoll.actions.content.rule.js' END
// 'js/skoll.actions.content.search.js' START:
/**
 * @file skoll.actions.content.search.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.search = {
	//
	// Protected properties.
	//
	// Public methods.
	sendQuery: function(form) {
		Skoll.tools.preventDefault();
		Skoll.actions.sidetools.search.setPattern($(form).find("#pattern").val());

		var type = $(form).find("#SearchType").val();
		var url = "?action=content:search&group=" + GROUP_ID + "&pattern=" + $(form).find("#pattern").val().replace(/ /g, "%20");

		var exceptions = $(form).find("#exceptions").val().replace(/ /g, "%20");
		if (exceptions != "") {
			url += "&exceptions=" + exceptions;
		}

		$.each($(form).find("#Types").find("input:checked"), function(key, item) {
			url += "&" + $(item).attr("name") + "=on";
		});

		document.location.href = url;
	}
	//
	// Protected methods.
};
// 'js/skoll.actions.content.search.js' END
// 'js/skoll.actions.content.user.js' START:
/**
 * @file skoll.actions.content.user.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.user = {
	//
	// Public methods.
	login: function() {
		Skoll.tools.preventDefault();
		Skoll.tools.Loading.start();
		var serviceUrl = "service.php?service=users:login" + Skoll.tools.extraUrlParams();
		Skoll.tools.log("Skoll.actions.content.user.login(): URL '" + serviceUrl + "'");
		$.ajax({
			dataType: "json",
			url: serviceUrl,
			type: "POST",
			data: {
				params: JSON.stringify({
					username: $("#username").val(),
					password: $("#password").val(),
					keepme: $("#rememberme:checked").length !== 0
				})
			},
			success: function(data) {
				if (data.status) {
					Skoll.tools.log("Login success");
					Skoll.tools.reload();
				} else {
					Skoll.tools.log("Login error: [" + data.error.code + "] " + data.error.message);
					alert("[" + data.error.code + "] " + data.error.message);
					Skoll.tools.Loading.stop();
				}
			},
			error: function(data) {
				Skoll.tools.log("Login error: " + data);
			}
		});
	},
	logout: function() {
		Skoll.tools.preventDefault();
		Skoll.tools.Loading.start();
		var serviceUrl = "service.php?service=users:logout" + Skoll.tools.extraUrlParams();
		Skoll.tools.log("Skoll.actions.content.user.logout(): URL '" + serviceUrl + "'");
		$.ajax({
			dataType: "json",
			url: serviceUrl,
			type: "POST",
			data: {
				params: JSON.stringify({})
			},
			success: function(data) {
				if (data.status) {
					Skoll.tools.log("Logout success");
					Skoll.tools.reloadHome();
				} else {
					Skoll.tools.log("Login error: [" + data.error.code + "] " + data.error.message);
					alert("[" + data.error.code + "] " + data.error.message);
					Skoll.tools.Loading.stop();
				}
			},
			error: function(data) {
				Skoll.tools.log("Login error: " + data);
			}
		});
	},
	//
	// Protected methods.
	_binds: function() {
	}
}
$(document).ready(function() {
	Skoll.actions.content.user._binds();
});// 'js/skoll.actions.content.user.js' END
// 'js/skoll.actions.content.cache.js' START:
/**
 * @file skoll.actions.content.cache.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.cache = {
	//
	// Protected variables.
	//
	// Public methods.
	flush: function(id) {
		Skoll.tools.Loading.start(0);
		Skoll.tools.preventDefault();

		$.ajax({
			type: "POST",
			url: "?action=content:cache&group=" + GROUP_ID + "&format=json&nolayout" + Skoll.tools.extraUrlParams(),
			data: {
				id: id,
				task: "flush"
			},
			dataType: "json",
			success: function(data) {
				console.log(data);
				if (data.status) {
					Skoll.tools.reload();
				} else {
					alert(data.error_message);
					Skoll.tools.Loading.stop();
				}
			},
			error: function(data) {
				console.log(data);
				if (typeof data.responseText != "undefined") {
					console.log(data.responseText);
				}

				alert(wcomix.lang.translate("message_unknown_error"));
				Skoll.tools.Loading.stop();
			}
		});
	}
	//
	// Protected methods.
};

//$(document).ready(function() {
//	Skoll.actions.content.comic.addShortCuts();
//});
// 'js/skoll.actions.content.cache.js' END
// 'js/skoll.actions.content.query.js' START:
/**
 * @file skoll.actions.content.query.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.content.query = {
	//
	// Protected properties.
	//
	// Public methods.
	search: function() {
		Skoll.tools.preventDefault();

		document.location.href = "?action=content:query&group=" + GROUP_ID + "&query=" + escape($("#query").val()) + Skoll.tools.extraUrlParams();
	}
	//
	// Protected methods.
};
// 'js/skoll.actions.content.query.js' END
// 'js/skoll.actions.sidetools.search.js' START:
/**
 * @file skoll.actions.sidetools.search.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.sidetools.search = {
	//
	// Protected properties.
	// 
	// Public methods.
	query: function(form) {
		Skoll.tools.preventDefault();

		document.location.href = "?action=content:query&group=" + GROUP_ID + "&query=" + escape($(form).find("#QueryPattern").val()) + Skoll.tools.extraUrlParams();
	},
	search: function(form) {
		Skoll.tools.preventDefault();

		var type = $(form).find("#SearchType").val();
		var url = "?action=content:search&group=" + GROUP_ID + "&pattern=" + $(form).find("#SearchPattern").val() + Skoll.tools.extraUrlParams();

		if (type != "") {
			url += "&O-" + type + "=on";
		}

		document.location.href = url;
	},
	setPattern: function(pattern) {
		$("#SearchPattern").val(pattern);
	},
	setQueryPattern: function(pattern) {
		$("#QueryPattern").val(pattern);
	}
};// 'js/skoll.actions.sidetools.search.js' END
// 'js/skoll.actions.rule.tare.js' START:
/**
 * @file skoll.actions.rule.tare.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.rule.tare = {
	//
	// Protected properties.
	//
	// Public methods.
	create: function(form, ruleId) {
		Skoll.tools.Loading.start(0);
		Skoll.tools.preventDefault();

		var nameInput = $(form).find("#action_name");
		var modeInput = $(form).find("#action_mode");
		var name = nameInput.val().trim();
		var mode = modeInput.val().trim();

		if (name.length > 0 && mode.length > 0) {
			$.ajax({
				type: "POST",
				url: "?action=rule:tare:create&group=" + GROUP_ID + "&rule=" + ruleId + "&format=json" + Skoll.tools.extraUrlParams(),
				data: {
					name: name,
					mode: mode
				},
				dataType: "json",
				success: function(data) {
					console.log(data);
					if (data.status) {
						window.location.href = "?action=rule:tare:edit&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + data.info_id + Skoll.tools.extraUrlParams();
					} else {
						alert(wcomix.lang.translate("message_unable_create_rule_action"));
						Skoll.tools.Loading.stop();
					}
				},
				error: function(data) {
					console.log(data);
					if (typeof data.responseText != "undefined") {
						console.log(data.responseText);
					}

					alert(wcomix.lang.translate("message_unknown_error"));
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			if (name.length <= 0) {
				nameInput.focus();
				alert(wcomix.lang.translate("message_request_name"));
			} else if (mode.length <= 0) {
				modeInput.focus();
				alert(wcomix.lang.translate("message_request_mode"));
			}

			Skoll.tools.Loading.stop();
		}
	},
	editALSO: function(form) {
		Skoll.actions.rule.tare._editGEN("ALSO", form);
	},
	editIF: function(form) {
		Skoll.actions.rule.tare._editGEN("IF", form);
	},
	editMERGE: function(form) {
		Skoll.actions.rule.tare._editGEN("MERGE", form);
	},
	editPOOL: function(form) {
		Skoll.tools.preventDefault();
		Skoll.tools.Loading.start(0);
		var ruleId = $(form).find("#ruleid").val();
		var actionId = $(form).find("#actionid").val();
		var url = "?action=rule:tare:edit&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + actionId + "&format=json&nolayout";

		var actionName = $(form).find("#name").val();
		var task = $(form).find("#task").val();

		var ids = "";
		var names = "";

		var send = false;
		if (task == "add") {
			names = $(form).find("#seek").val().split(",");
			if (names.length !== 0) {
				send = true;
			} else {
				alert(wcomix.lang.translate("message_nothing_selected"));
				Skoll.tools.Loading.stop();
			}
		} else if (task == "remove") {
			ids = [];
			var tagsSelected = $(form).find("#currents").find("input:checked");
			$.each(tagsSelected, function(key, item) {
				ids.push($(item).attr("wctag"));
			});
			if (ids.length !== 0) {
				send = true;
			} else {
				alert(wcomix.lang.translate("message_nothing_selected"));
				Skoll.tools.Loading.stop();
			}
		} else {
			alert(wcomix.lang.translate("message_nothing_selected"));
			Skoll.tools.Loading.stop();
		}

		if (send) {
			$.ajax({
				dataType: "json",
				url: url,
				type: "POST",
				data: {
					name: actionName,
					mode: "POOL",
					task: task,
					ids: ids,
					names: names,
					tag: ""
				},
				success: function(data) {
					if (!data.status) {
						alert(data.status_message);
						Skoll.tools.Loading.stop();
					} else {
						Skoll.tools.reload();
					}
				},
				error: function(data) {
					Skoll.tools.log("Tags settings error: " + data);
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			alert(wcomix.lang.translate("message_nothing_to_send"));
			Skoll.tools.Loading.stop();
		}

		$('#task').val('add');
	},
	//
	// Protected methods.
	_editGEN: function(mode, form) {
		Skoll.tools.preventDefault();
		Skoll.tools.Loading.start(0);

		var ruleId = $(form).find("#ruleid").val();
		var actionId = $(form).find("#actionid").val();
		var url = "?action=rule:tare:edit&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + actionId + "&format=json&nolayout";

		var actionName = $(form).find("#name").val();
		var task = $(form).find("#task").val();

		var ids = "";
		var names = "";
		var tag = $(form).find("#tag").val();

		var send = false;
		if (task == "add") {
			names = $(form).find("#seek").val().split(",");
			if (names.length !== 0) {
				send = true;
			} else {
				alert(wcomix.lang.translate("message_nothing_selected"));
				Skoll.tools.Loading.stop();
			}
		} else if (task == "remove") {
			ids = [];
			var tagsSelected = $(form).find("#currents").find("input:checked");
			$.each(tagsSelected, function(key, item) {
				ids.push($(item).attr("wctag"));
			});
			if (ids.length !== 0) {
				send = true;
			} else {
				alert(wcomix.lang.translate("message_nothing_selected"));
				Skoll.tools.Loading.stop();
			}
		} else {
			alert(wcomix.lang.translate("message_nothing_selected"));
			Skoll.tools.Loading.stop();
		}

		if (send) {
			$.ajax({
				dataType: "json",
				url: url,
				type: "POST", data: {
					name: actionName,
					mode: mode,
					task: task,
					ids: ids,
					names: names,
					tag: tag
				},
				success: function(data) {
					if (!data.status) {
						alert(data.status_message);
						Skoll.tools.Loading.stop();
					} else {
						Skoll.tools.reload();
					}
				},
				error: function(data) {
					Skoll.tools.log("Tags settings error: " + data);
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			alert(wcomix.lang.translate("message_nothing_to_send"));
			Skoll.tools.Loading.stop();
		}

		$('#task').val('add');
	}
};
// 'js/skoll.actions.rule.tare.js' END
// 'js/skoll.actions.rule.dor.js' START:
/**
 * @file skoll.actions.rule.dor.js
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: skoll.full.js 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/skins/Skoll/js/skoll.full.js $
 */

Skoll.actions.rule.dor = {
	//
	// Protected properties.
	//
	// Public methods.
	create: function(form, ruleId) {
		Skoll.tools.Loading.start(0);
		Skoll.tools.preventDefault();

		var nameInput = $(form).find("#action_name");
		var modeInput = $(form).find("#action_mode");
		var name = nameInput.val().trim();
		var mode = modeInput.val().trim();

		if (name.length > 0 && mode.length > 0) {
			$.ajax({
				type: "POST",
				url: "?action=rule:dor:create&group=" + GROUP_ID + "&rule=" + ruleId + "&format=json" + Skoll.tools.extraUrlParams(),
				data: {
					name: name,
					mode: mode
				},
				dataType: "json",
				success: function(data) {
					console.log(data);
					if (data.status) {
						window.location.href = "?action=rule:dor:edit&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + data.info_id + Skoll.tools.extraUrlParams();
					} else {
						alert(wcomix.lang.translate("message_unable_create_rule_action"));
						Skoll.tools.Loading.stop();
					}
				},
				error: function(data) {
					console.log(data);
					if (typeof data.responseText != "undefined") {
						console.log(data.responseText);
					}

					alert(wcomix.lang.translate("message_unknown_error"));
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			if (name.length <= 0) {
				nameInput.focus();
				alert(wcomix.lang.translate("message_request_name"));
			} else if (mode.length <= 0) {
				modeInput.focus();
				alert(wcomix.lang.translate("message_request_mode"));
			}

			Skoll.tools.Loading.stop();
		}
	},
	editCMOVE: function(form) {
		Skoll.actions.rule.dor._editGENDirCol("CMOVE", form);
	},
	editCOLLECTOR: function(form) {
		Skoll.actions.rule.dor._editGENDirCol("COLLECTOR", form);
	},
	editMOVE: function(form) {
		Skoll.actions.rule.dor._editGENDirTag("MOVE", form);
	},
	editTAGGER: function(form) {
		Skoll.actions.rule.dor._editGENDirTag("TAGGER", form);
	},
	editVMOVE: function(form) {
		Skoll.actions.rule.dor._editGENDirTag("VMOVE", form);
	},
	//
	// Protected methods.
	_editGENDirTag: function(mode, form) {
		Skoll.tools.preventDefault();
		Skoll.tools.Loading.start(0);

		var ruleId = $(form).find("#ruleid").val();
		var actionId = $(form).find("#actionid").val();
		var url = "?action=rule:dor:edit&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + actionId + "&format=json&nolayout";

		var actionName = $(form).find("#name").val();
		var directory = $(form).find("#directory").val();
		var tags = $(form).find("#tags").val();
		var status = $(form).find("#status").val();

		var send = true;

		if (send) {
			$.ajax({
				dataType: "json",
				url: url,
				type: "POST", data: {
					name: actionName,
					mode: mode,
					directory: directory,
					tags: tags,
					status: status
				},
				success: function(data) {
					if (!data.status) {
						alert(data.status_message);
						Skoll.tools.Loading.stop();
					} else {
						Skoll.tools.reload();
					}
				},
				error: function(data) {
					Skoll.tools.log("Tags settings error: " + data);
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			alert(wcomix.lang.translate("message_nothing_to_send"));
			Skoll.tools.Loading.stop();
		}
	},
	_editGENDirCol: function(mode, form) {
		Skoll.tools.preventDefault();
		Skoll.tools.Loading.start(0);

		var ruleId = $(form).find("#ruleid").val();
		var actionId = $(form).find("#actionid").val();
		var url = "?action=rule:dor:edit&group=" + GROUP_ID + "&rule=" + ruleId + "&raction=" + actionId + "&format=json&nolayout";

		var actionName = $(form).find("#name").val();
		var directory = $(form).find("#directory").val();
		var collection = $(form).find("#collection").val();
		var status = $(form).find("#status").val();

		var send = true;

		if (send) {
			$.ajax({
				dataType: "json",
				url: url,
				type: "POST", data: {
					name: actionName,
					mode: mode,
					directory: directory,
					collection: collection,
					status: status
				},
				success: function(data) {
					if (!data.status) {
						alert(data.status_message);
						Skoll.tools.Loading.stop();
					} else {
						Skoll.tools.reload();
					}
				},
				error: function(data) {
					Skoll.tools.log("Tags settings error: " + data);
					Skoll.tools.Loading.stop();
				}
			});
		} else {
			alert(wcomix.lang.translate("message_nothing_to_send"));
			Skoll.tools.Loading.stop();
		}
	}
};
// 'js/skoll.actions.rule.dor.js' END
